package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsRoleMapper;
import com.qf.pojo.DtsRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author sunyamei
 * @version V1.0
 * @Project javase2203
 * @Package com.qf.service
 * @Description:
 * @Date 2022/7/25 20:22
 */
@Service
public class RoleServiceImpl implements  RoleService{

    @Autowired
    private DtsRoleMapper roleMapper;

    @Override
    public Set<String> queryRolesById(Integer[] roleIds) {
        //创建条件查询对象
        QueryWrapper<DtsRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("id", roleIds);

     List<DtsRole> list= roleMapper.selectList(queryWrapper);

     //遍历角色集合,获取名字
        Set<String> roleSet = new HashSet<>();
        if (list != null){
            for (DtsRole dtsRole :list){
                roleSet.add(dtsRole.getName());
            }
        }
        return roleSet;
    }
}
